<!DOCTYPE html>
<html>
  <head>
    <title>Cathode Retro Docs</title>
    <link href="../../docs.css" rel="stylesheet">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" charset="UTF-8">
    <script src="../../main-scripts.js"></script>
  </head>
  <body onload="OnLoad()" class="page">
    <header class="header"><button id="sidebar-button"></button></header>
    <div id="sidebar-container" class="sidebar-container"><iframe class="sidebar-frame" src="../../sidebar.html?page=shader-reference-generator-apply-artifacts"></iframe></div>
    <div id="content-outer" class="content-outer">
      <main>
        <h1>generator-apply-artifacts</h1>
        <p>
          This shader applies ghosting and noise to an SVideo or Composite signal.
        </p>
        <p>
          Noise is just that: some randomized signal offset per sample to simulate analog error in the signal (like "snow")
        </p>
        <p>
          Ghosting basically is what happens when a copy of your signal "skips" its intended path through the cable and mixes
          in with your normal signal (like an EM leak of the signal) and is basically a pre-echo of the signal. So as a very
          rough approximation of this, we'll just blend in an offset, blurred, and scaled version of the original signal.
        </p>
        <h2>Index</h2>
        <div class="index">
          <h3>Input Textures/Samplers</h3>
          <nav>
            <menu>
              <li><a href="#g_sourceTexture">g_sourceTexture</a></li>
              <li><a href="#g_sampler">g_sampler</a></li>
            </menu>
          </nav>
          <h3>Uniform Buffer Values</h3>
          <nav>
            <menu>
              <li><a href="#g_ghostVisibility">g_ghostVisibility</a></li>
              <li><a href="#g_ghostDistance">g_ghostDistance</a></li>
              <li><a href="#g_ghostSpreadScale">g_ghostSpreadScale</a></li>
              <li><a href="#g_noiseStrength">g_noiseStrength</a></li>
              <li><a href="#g_noiseSeed">g_noiseSeed</a></li>
              <li><a href="#g_signalTextureWidth">g_signalTextureWidth</a></li>
              <li><a href="#g_scanlineCount">g_scanlineCount</a></li>
              <li><a href="#g_samplesPerColorburstCycle">g_samplesPerColorburstCycle</a></li>
            </menu>
          </nav>
        </div>
        <h2>Input Textures/Samplers</h2>
        <dl class="member-list">
          <dt id="g_sourceTexture">g_sourceTexture</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                g_sourceTexture
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>texture</code> (platform-specific)
            </section>
            <h5>Description</h5>
            <section>
              The texture to sample.
            </section>
          </dd>
          <dt id="g_sampler">g_sampler</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                g_sampler
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>sampler</code> (platform-specific, does not exist on some platforms)
            </section>
            <h5>Description</h5>
            <section>
              The sampler to use to sample <a href="#g_sourceTexture">g_sourceTexture</a>.
            </section>
          </dd>
        </dl>
        <h2>Uniform Buffer Values</h2>
        <dl class="member-list">
          <dt id="g_ghostVisibility">g_ghostVisibility</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                float g_ghostVisibility
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>g_ghostVisibility</code>
            </section>
            <h5>Description</h5>
            <section>
              This represents how much ghosting is visible - 
              <code>0.0</code> is "no ghosting" and <code>1.0</code> is "the ghost is as strong as the original signal."
            </section>
          </dd>
          <dt id="g_ghostDistance">g_ghostDistance</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                float g_ghostDistance
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>float</code>
            </section>
            <h5>Description</h5>
            <section>
              This is the distance (in colorburst cycles) before the original signal that ghosting should appear.
            </section>
          </dd>
          <dt id="g_ghostSpreadScale">g_ghostSpreadScale</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                float g_ghostSpreadScale
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>float</code>
            </section>
            <h5>Description</h5>
            <section>
              How far to blur the ghost, in colorburst cycles.
            </section>
          </dd>
          <dt id="g_noiseStrength">g_noiseStrength</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                float g_noiseStrength
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>float</code>
            </section>
            <h5>Description</h5>
            <section>
              The strength of noise to add to the signal - <code>0.0</code> means no noise, <code>1.0</code> means, just, a lot of noise. So much.
              Probably too much.
            </section>
          </dd>
          <dt id="g_noiseSeed">g_noiseSeed</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                uint g_noiseSeed
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>uint</code>
            </section>
            <h5>Description</h5>
            <section>
              An integer seed used to generate the per-output-texel noise. This can be a monotonically-increasing value, or
              random every frame, just as long as it's different every frame so that the noise changes.
            </section>
          </dd>
          <dt id="g_signalTextureWidth">g_signalTextureWidth</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                uint g_signalTextureWidth
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>uint</code>
            </section>
            <h5>Description</h5>
            <section>
              The width of the input signal texture, in texels.
            </section>
          </dd>
          <dt id="g_scanlineCount">g_scanlineCount</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                uint g_scanlineCount
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>uint</code>
            </section>
            <h5>Description</h5>
            <section>
              The number of scanlines in this field of NTSC video (i.e. the height of the signal texture).
            </section>
          </dd>
          <dt id="g_samplesPerColorburstCycle">g_samplesPerColorburstCycle</dt>
          <dd>
            <div class="code-definition syntax-hlsl">
              <pre>
                uint g_samplesPerColorburstCycle
              </pre>
            </div>
            <h5>Type</h5>
            <section>
              <code>uint</code>
            </section>
            <h5>Description</h5>
            <section>
              How many samples (texels along a scanline) there are per colorburst cycle (the color wave in the composite signal)
            </section>
          </dd>
        </dl>
      </main>
    </div>
  </body>
</html>